package com.atguigu.dp;

//3.斐波那契数列 - 放弃递归
public class Demo03 {
    public static void main(String[] args) {
        for(int i = 0 ; i<=100 ; i++){
            System.out.println(i+"  :  " + fn(i));
        }
    }

    private static long[] cache = new long[101];

    public static long fn(int n){
        cache[0] = 0 ;
        cache[1] = 1 ;

        for(int i = 2 ; i<=n ;i++){
            cache[i] = cache[i-2]+cache[i-1];
        }
        return cache[n];
    }
}
